---
title: "Figure A.6"
output: 
---

# Figure A.6

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("ggpubfigs")
# install.packages("scales")
# devtools::install_github("JLSteenwyk/ggpubfigs")

#load packages
```{r}
library(tidyverse)
library(ggpubfigs)
library(scales)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#relabel attention variable for plot
```{r relabel attention}
survey_clean <- survey_clean %>% mutate(attention_cat_verbose = case_when(
Q62 == 1 ~ "1 (Very Inattentive)",
Q62 == 2 ~ "2",
Q62 == 3 ~ "3",
Q62 == 4 ~ "4",
Q62 == 5 ~ "5",
Q62 == 6 ~ "6 (Very Attentive)",
TRUE ~ "NA"
))
```

#plot attention variable
```{r attention plot}
attention_plot <- survey_clean %>% group_by(attention_cat_verbose) %>% summarise(attention_prop = n() / nrow(survey_clean)) %>% ggplot(aes(y = attention_prop, x=attention_cat_verbose, fill = attention_cat_verbose)) +
geom_bar(stat = "identity") +
  scale_y_continuous(limits = c(0, .75), labels=percent_format()) +
  scale_fill_manual(name = "", values = friendly_pal("muted_nine", 6)) +
  labs(
    title = "",
    x = "",
    y = "",
    fill = ""
  ) +
  theme_minimal() +
  theme(legend.position = "none",
    axis.text.x = element_text(angle = 45, hjust = 1, size = 8, face = "bold")
  )  
```